Run download_data.Rmd and percentage_of_regional_richness.Rmd First!
library(randomForest)
library(reshape2)
library(rpart)
library(ggplot2)
library(tidyverse)
library(multcomp)
library(car)
library(VSURF)
library(boot)
length(city_data$city_gdp_per_population[!is.na(city_data$city_gdp_per_population)])
[1] 30
length(city_data$percentage_urban_area_as_open_public_spaces[!is.na(city_data$percentage_urban_area_as_open_public_spaces)])
[1] 61
length(city_data$happiness_future_life[!is.na(city_data$happiness_future_life)])
[1] 65
length(city_data$mean_population_exposure_to_pm2_5_2019[!is.na(city_data$mean_population_exposure_to_pm2_5_2019)])
[1] 131
fetch_city_data_for <- function(pool_name, include_city_name = F) {
results_filename <- paste(paste('percentage_of_regional_richness__output_', pool_name, 'city', 'richness', 'intercept', sep = "_"), "csv", sep = ".")
results <- read_csv(results_filename)
joined <- left_join(city_data, results)
required_columns <- c("population_growth", "rainfall_monthly_min", "rainfall_annual_average", "rainfall_monthly_max", "temperature_annual_average", "temperature_monthly_min", "temperature_monthly_max", "happiness_negative_effect", "happiness_positive_effect", "happiness_future_life", "number_of_biomes", "realm", "biome_name", "region_20km_includes_estuary", "region_50km_includes_estuary", "region_100km_includes_estuary", "city_includes_estuary", "region_20km_average_pop_density", "region_50km_average_pop_density", "region_100km_average_pop_density", "city_max_pop_density", "city_average_pop_density", "mean_population_exposure_to_pm2_5_2019", "region_20km_cultivated", "region_20km_urban", "region_50km_cultivated", "region_50km_urban", "region_100km_cultivated", "region_100km_urban", "region_20km_elevation_delta", "region_20km_mean_elevation", "region_50km_elevation_delta", "region_50km_mean_elevation", "region_100km_elevation_delta", "region_100km_mean_elevation", "city_elevation_delta", "city_mean_elevation", "urban", "shrubs", "permanent_water", "open_forest", "herbaceous_wetland", "herbaceous_vegetation", "cultivated", "closed_forest", "share_of_population_within_400m_of_open_space", "percentage_urban_area_as_streets", "percentage_urban_area_as_open_public_spaces_and_streets", "percentage_urban_area_as_open_public_spaces", "city_gdp_per_population", "city_ndvi", "city_ssm", "city_susm", "region_20km_ndvi", "region_20km_ssm", "region_20km_susm", "region_50km_ndvi", "region_50km_ssm", "region_50km_susm", "region_100km_ndvi", "region_100km_ssm", "region_100km_susm", "city_percentage_protected", "region_20km_percentage_protected", "region_50km_percentage_protected", "region_100km_percentage_protected")
if (include_city_name) {
required_columns <- append(c("name"), required_columns)
}
required_columns <- append(c("response"), required_columns)
joined[,required_columns]
}
| Merlin Response |
merlin_city_data <- fetch_city_data_for('merlin')
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
name = col_character(),
response = col_double()
)
Joining, by = "name"
merlin_city_data
merlin_city_data_fixed <- rfImpute(response ~ ., merlin_city_data)
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 21.17 117.46 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 20.9 115.96 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 20.95 116.22 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 21.01 116.56 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 21.82 121.06 |
merlin_city_data_fixed
names(merlin_city_data_fixed)
merlin_interp <- VSURF(x = merlin_predictors, y = merlin_response)
names(merlin_predictors[,merlin_interp$varselect.interp])
[1] "region_50km_elevation_delta" "biome_name" "region_50km_ssm" "region_100km_ssm"
| Birdlife Response |
birdlife_city_data <- fetch_city_data_for('birdlife')
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
name = col_character(),
response = col_double()
)
Joining, by = "name"
birdlife_city_data
birdlife_city_data_fixed <- rfImpute(response ~ ., birdlife_city_data)
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 5.752 91.05 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 5.722 90.57 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 5.783 91.54 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 5.8 91.81 |
| Out-of-bag |
Tree | MSE %Var(y) |
300 | 5.839 92.43 |
birdlife_city_data_fixed
names(merlin_city_data_fixed)
[1] "response" "population_growth"
[3] "rainfall_monthly_min" "rainfall_annual_average"
[5] "rainfall_monthly_max" "temperature_annual_average"
[7] "temperature_monthly_min" "temperature_monthly_max"
[9] "happiness_negative_effect" "happiness_positive_effect"
[11] "happiness_future_life" "number_of_biomes"
[13] "realm" "biome_name"
[15] "region_20km_includes_estuary" "region_50km_includes_estuary"
[17] "region_100km_includes_estuary" "city_includes_estuary"
[19] "region_20km_average_pop_density" "region_50km_average_pop_density"
[21] "region_100km_average_pop_density" "city_max_pop_density"
[23] "city_average_pop_density" "mean_population_exposure_to_pm2_5_2019"
[25] "region_20km_cultivated" "region_20km_urban"
[27] "region_50km_cultivated" "region_50km_urban"
[29] "region_100km_cultivated" "region_100km_urban"
[31] "region_20km_elevation_delta" "region_20km_mean_elevation"
[33] "region_50km_elevation_delta" "region_50km_mean_elevation"
[35] "region_100km_elevation_delta" "region_100km_mean_elevation"
[37] "city_elevation_delta" "city_mean_elevation"
[39] "urban" "shrubs"
[41] "permanent_water" "open_forest"
[43] "herbaceous_wetland" "herbaceous_vegetation"
[45] "cultivated" "closed_forest"
[47] "share_of_population_within_400m_of_open_space" "percentage_urban_area_as_streets"
[49] "percentage_urban_area_as_open_public_spaces_and_streets" "percentage_urban_area_as_open_public_spaces"
[51] "city_gdp_per_population" "city_ndvi"
[53] "city_ssm" "city_susm"
[55] "region_20km_ndvi" "region_20km_ssm"
[57] "region_20km_susm" "region_50km_ndvi"
[59] "region_50km_ssm" "region_50km_susm"
[61] "region_100km_ndvi" "region_100km_ssm"
[63] "region_100km_susm" "city_percentage_protected"
[65] "region_20km_percentage_protected" "region_50km_percentage_protected"
[67] "region_100km_percentage_protected"
birdlife_interp <- VSURF(x = birdlife_predictors, y = birdlife_response)
Thresholding step
Estimated computational time (on one core): 102.4 sec.
|
| | 0%
|
|=== | 2%
|
|====== | 4%
|
|========= | 6%
|
|=========== | 8%
|
|============== | 10%
|
|================= | 12%
|
|==================== | 14%
|
|======================= | 16%
|
|========================== | 18%
|
|============================= | 20%
|
|=============================== | 22%
|
|================================== | 24%
|
|===================================== | 26%
|
|======================================== | 28%
|
|=========================================== | 30%
|
|============================================== | 32%
|
|================================================= | 34%
|
|=================================================== | 36%
|
|====================================================== | 38%
|
|========================================================= | 40%
|
|============================================================ | 42%
|
|=============================================================== | 44%
|
|================================================================== | 46%
|
|===================================================================== | 48%
|
|======================================================================== | 50%
|
|========================================================================== | 52%
|
|============================================================================= | 54%
|
|================================================================================ | 56%
|
|=================================================================================== | 58%
|
|====================================================================================== | 60%
|
|========================================================================================= | 62%
|
|============================================================================================ | 64%
|
|============================================================================================== | 66%
|
|================================================================================================= | 68%
|
|==================================================================================================== | 70%
|
|======================================================================================================= | 72%
|
|========================================================================================================== | 74%
|
|============================================================================================================= | 76%
|
|================================================================================================================ | 78%
|
|================================================================================================================== | 80%
|
|===================================================================================================================== | 82%
|
|======================================================================================================================== | 84%
|
|=========================================================================================================================== | 86%
|
|============================================================================================================================== | 88%
|
|================================================================================================================================= | 90%
|
|==================================================================================================================================== | 92%
|
|====================================================================================================================================== | 94%
|
|========================================================================================================================================= | 96%
|
|============================================================================================================================================ | 98%
|
|===============================================================================================================================================| 100%
Interpretation step (on 45 variables)
Estimated computational time (on one core): between 60.7 sec. and 366.8 sec.
|
| | 0%
|
|=== | 2%
|
|====== | 4%
|
|========== | 7%
|
|============= | 9%
|
|================ | 11%
|
|=================== | 13%
|
|====================== | 16%
|
|========================= | 18%
|
|============================= | 20%
|
|================================ | 22%
|
|=================================== | 24%
|
|====================================== | 27%
|
|========================================= | 29%
|
|============================================ | 31%
|
|================================================ | 33%
|
|=================================================== | 36%
|
|====================================================== | 38%
|
|========================================================= | 40%
|
|============================================================ | 42%
|
|================================================================ | 44%
|
|=================================================================== | 47%
|
|====================================================================== | 49%
|
|========================================================================= | 51%
|
|============================================================================ | 53%
|
|=============================================================================== | 56%
|
|=================================================================================== | 58%
|
|====================================================================================== | 60%
|
|========================================================================================= | 62%
|
|============================================================================================ | 64%
|
|=============================================================================================== | 67%
|
|=================================================================================================== | 69%
|
|====================================================================================================== | 71%
|
|========================================================================================================= | 73%
|
|============================================================================================================ | 76%
|
|=============================================================================================================== | 78%
|
|================================================================================================================== | 80%
|
|====================================================================================================================== | 82%
|
|========================================================================================================================= | 84%
|
|============================================================================================================================ | 87%
|
|=============================================================================================================================== | 89%
|
|================================================================================================================================== | 91%
|
|===================================================================================================================================== | 93%
|
|========================================================================================================================================= | 96%
|
|============================================================================================================================================ | 98%
|
|===============================================================================================================================================| 100%
Prediction step (on 2 variables)
Maximum estimated computational time (on one core): 2.6 sec.
|
| | 0%
|
|======================================================================== | 50%
|
|===============================================================================================================================================| 100%
names(birdlife_predictors[,birdlife_interp$varselect.interp])
[1] "population_growth" "region_50km_ssm"
| So…. |
|---|
| Merlin: “region_50km_elevation_delta” “biome_name” “region_50km_ssm” “region_100km_ssm” Birdlife: “population_growth” “region_50km_ssm” |
birdlife_city_data_named <- fetch_city_data_for('birdlife', T)
── Column specification ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
cols(
name = col_character(),
response = col_double()
)
Joining, by = "name"
| Use cross validation and dropping terms to find best model |
full model: response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + biome_name + population_growth
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + biome_name + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 19.72841
– CVE 19.72841 – Can we drop one?
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + region_50km_elevation_delta + biome_name + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 19.39392
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta + biome_name + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 19.3626
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + biome_name + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 19.79173
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.53183
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + biome_name, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 19.38052
– drop biome_name to give smaller CVE of 18.53183 – can we drop another?
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + region_50km_elevation_delta + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.26184
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.24017
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + population_growth, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.79038
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.20095
– drop population_growth to give CVE of 18.20095 – can we drop another?
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + region_50km_elevation_delta, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 17.9362
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 17.91216
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.48549
– drop region_50km_ssm to give CVE of 17.91216 – can we drop another?
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.19515
cv.glm(merlin_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_elevation_delta, data = merlin_city_data_fixed_no_boreal))$delta[1]
[1] 18.04985
| – best model with region_100km_ssm + region_50km_elevation_delta (CV error 17.91216) |
summary(glm(data = merlin_city_data_fixed, formula = response ~ region_100km_ssm + region_50km_elevation_delta))
Call:
glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta,
data = merlin_city_data_fixed)
Deviance Residuals:
Min 1Q Median 3Q Max
-7.6599 -2.9987 -0.5524 1.7449 16.9143
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.6809304 1.1210300 2.391 0.0182 *
region_100km_ssm -0.1331207 0.0695604 -1.914 0.0578 .
region_50km_elevation_delta -0.0006899 0.0003461 -1.994 0.0482 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 17.36262)
Null deviance: 2469.6 on 136 degrees of freedom
Residual deviance: 2326.6 on 134 degrees of freedom
AIC: 784.8
Number of Fisher Scoring iterations: 2
reg_merlin = glm(data = merlin_city_data_fixed, formula = response ~ region_100km_ssm + region_50km_elevation_delta)
with(summary(reg_merlin), 1 - deviance/null.deviance)
[1] 0.05791102
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + biome_name + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.899862
– can we drop a variable?
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + region_50km_elevation_delta + biome_name + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.768164
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta + biome_name + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.752211
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + biome_name + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.989636
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.503421
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta + biome_name, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.780578
– drop biome_name to give CVE of 6.503421 – can we drop another?
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + region_50km_elevation_delta + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.417311
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.426562
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.430742
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_100km_ssm + region_50km_ssm + region_50km_elevation_delta, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.439714
– drop region_100km_ssm to give CVE of 6.417311 – can we drop another?
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_elevation_delta + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.535285
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.342025
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm + region_50km_elevation_delta, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.352664
– drop region_50km_elevation_delta to give CVE of 6.342025 – can we drop another?
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ population_growth, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.464699
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ region_50km_ssm, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.291299
– drop city_gdp_per_population to give CVE of 6.291299 – is this better than no variable?
cv.glm(birdlife_city_data_fixed_no_boreal, glm(formula = response ~ 1, data = birdlife_city_data_fixed_no_boreal))$delta[1]
[1] 6.395701
– yes, just!
| – so best model with birdlife is region_50km_ssm |
summary(glm(data = birdlife_city_data_fixed, formula = response ~ region_50km_ssm))
Call:
glm(formula = response ~ region_50km_ssm, data = birdlife_city_data_fixed)
Deviance Residuals:
Min 1Q Median 3Q Max
-4.5353 -1.5461 -0.4124 1.3071 10.7572
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1.26916 0.65041 1.951 0.0531 .
region_50km_ssm -0.08499 0.04115 -2.065 0.0408 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 6.214378)
Null deviance: 865.45 on 136 degrees of freedom
Residual deviance: 838.94 on 135 degrees of freedom
AIC: 643.06
Number of Fisher Scoring iterations: 2
reg_birdlife = glm(data = birdlife_city_data_fixed, formula = response ~ region_50km_ssm)
with(summary(reg_birdlife), 1 - deviance/null.deviance)
[1] 0.03062471
ggplot(birdlife_city_data_named, aes(x = region_50km_ssm, y = response)) + geom_point() + geom_smooth(method = "glm")
`geom_smooth()` using formula 'y ~ x'
| Check birdlife model fit |
birdlife_city_data_fixed_no_boreal[c(16, 53, 72), c("region_50km_ssm")]
[1] 18.451180 9.961682 11.644862
dat <- predict(glm(formula = response ~ region_50km_ssm, data = birdlife_city_data_named), se.fit=T)
outside_se <- birdlife_city_data_named[birdlife_city_data_named$response < dat$fit - 15* dat$se.fit | birdlife_city_data_named$response > dat$fit + 15 * dat$se.fit,]
ggplot(birdlife_city_data_named, aes(x = region_50km_ssm, y = response)) +
geom_point(size=1) +
geom_smooth(method = "glm") +
geom_text(aes(label = name), data = outside_se, size = 3, position = "dodge", vjust = "inward", hjust = "inward", color = "red", angle=-15) +
geom_point(data = outside_se, color = "red") +
theme_bw() +
ylab("City Random Effect Intercept") + xlab("Regional (50km) SSM") + labs(title = "Birdlife")
`geom_smooth()` using formula 'y ~ x'
Warning: Width not defined. Set with `position_dodge(width = ?)`
ggsave("city_effect_richness__output__birdlife.jpg")
Saving 7.29 x 4.51 in image
`geom_smooth()` using formula 'y ~ x'
Warning: Width not defined. Set with `position_dodge(width = ?)`
ggplot(birdlife_city_data_named, aes(y = response, x = residuals)) +
geom_point() +
geom_smooth(method = "lm", se = F) +
labs(title = "Birdlife", subtitle = paste("Correlation", cor(birdlife_city_data_named$residuals, birdlife_city_data_named$response))) +
theme_bw()
`geom_smooth()` using formula 'y ~ x'
| Check Merlin model fit |
merlin.fit <- glm(data = merlin_city_data_named, formula = response ~ region_100km_ssm + region_50km_elevation_delta)
summary(merlin.fit)
Call:
glm(formula = response ~ region_100km_ssm + region_50km_elevation_delta,
data = merlin_city_data_named)
Deviance Residuals:
Min 1Q Median 3Q Max
-7.6599 -2.9987 -0.5524 1.7449 16.9143
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.6809304 1.1210300 2.391 0.0182 *
region_100km_ssm -0.1331207 0.0695604 -1.914 0.0578 .
region_50km_elevation_delta -0.0006899 0.0003461 -1.994 0.0482 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
(Dispersion parameter for gaussian family taken to be 17.36262)
Null deviance: 2469.6 on 136 degrees of freedom
Residual deviance: 2326.6 on 134 degrees of freedom
AIC: 784.8
Number of Fisher Scoring iterations: 2
with(summary(merlin.fit), 1 - deviance/null.deviance)
[1] 0.05791102
plot(merlin.fit)
ggplot(merlin_city_data_named, aes(x = region_100km_ssm, y = response)) +
geom_point(aes(size = region_50km_elevation_delta)) +
geom_smooth(method = "glm") +
theme_bw() +
theme(legend.position="bottom") +
ylab("City Random Effect Intercept") + xlab("Regional (100km) SSM") + labs(title = "eBird") + guides(size=guide_legend(title="Regional (50km) Elevation Delta"))
`geom_smooth()` using formula 'y ~ x'
ggplot(merlin_city_data_named, aes(y = response, x = residuals)) +
geom_point() +
geom_smooth(method = "lm", se = F) +
labs(title = "Merlin", subtitle = paste("Correlation", cor(merlin_city_data_named$residuals, merlin_city_data_named$response))) +
theme_bw()
`geom_smooth()` using formula 'y ~ x'
| Check AIC |